Check if App is Compatible with PHP 7

How to Check if Your Application is Compatible with PHP 7

PHP 7 has been out for a while now, and it brings some real improvements over the older PHP 5 versions. Version 7 is twice as fast based on WordPress performance tests, as well as having a whole bunch of security improvements that make it a “must have” software upgrade for any PHP application. PHP 5 versions have already reached their end-of-life support, so it’s crucial for you to move to PHP 7.

Before you upgrade to PHP 7 however, it’s important to check whether or not your existing PHP application is compatible with the new version. This is probably one of the biggest reasons why many web hosts haven’t upgraded to PHP 7 – a lot of their clients are still using an older codebase with functions that no longer work, or work differently compared to before. If you have the option to move to PHP 7, then we suggest you take an inventory of your code and see what you need to change in order to make it compatible with PHP 7.

Checking PHP 7 Compatibility

Due to a large number of changes and improvements in PHP 7, it would be time-consuming and inefficient to manually go through your code and check for compatibility issues – in fact, it’s so easy to miss some deprecations, you would likely have to cover it several times over. What will help save both time and stress is a convenient tool that accepts your PHP files as an argument, runs them line-by-line against the new coding standards and functions of PHP 7, which then gives you a convenient readout of what you need to change. Luckily, such a tool exists, called the PHP 7 Migration Assistant Report. It can do everything we need it to in order to check our software for deprecated code.

In this tutorial, we will show you how to install and use the PHP 7 Migration Assistant Report on a Linux VPS.

Installing the PHP 7 Migration Assistant Report (MAR)

There are a few tools available that check for compatibility, including the PHPStorm IDE (which isn’t free). But the open-source PHP 7 Migration Assistant Report is one of the easiest to use. Once we download it from the GitHub repo, we can simply run it by providing the path to our PHP files for it to check.

NOTE: You will need a working setup of PHP installed on your Linux machine.

It consists of the following steps:

  1. Downloading the zip file from GitHub
  2. Unzipping it into a folder
  3. Getting the location of the PHP files we want to check
  4. Running the command against the location
  5. Analyzing the report
  6. Making changes

Let’s begin.

Downloading PHP 7 MAR from GitHub

Below you will find the commands needed to download and extract PHP 7 MAR. In case the link in the command no longer works, navigate to the download page for PHP 7 MAR and click on the green “Clone or download” button. Then, copy the link target as shown here:

Download ZIP File of Project

Now, log in to your server via SSH, and type in the following commands:

wget https://github.com/Alexia/php7mar/archive/master.zip

unzip -q master.zip

cd php7mar-master

This will create a new folder in your directory, like this:

Unzip the File and Enter the Directory

We now need to get the location of our PHP files.

Getting the PHP Files

As an example, we’ll use the latest version of WordPress. Most of the core PHP files are located in the directory “wp-includes”. You can use your application instead, so find the location of the folder containing the PHP files, and you’ll use it in the next step.

Checking an Example Folder Against PHP 7 MAR

To do this, go into the php7mar-master folder that we got in the first step, and type in the following:

php mar.php -f="[path to your folder containing PHP files]"

Here, replace [path to your folder containing PHP files] with the path on your server. Do not give the path to a specific PHP file if you want to check the entire folder. This will now generate an output like this:

PHP Report Generated

It gives you the location of the report. It’s can be confusing to access this file using text editors since the filename is broken up into parts. To get around this, you need to use double-quotes (“) around it to properly refer to the file. In this case, we can view the report using the standard “vi” editor like this in the “reports” folder:

vi "2019-01-29 11.13.34 wp-includes.md"

And here’s how the report should look if errors are present:

List of Deprecated Functions

As you can see, it gives you a line-by-line list of the changes that need to be made to your code, along with each file name in the folder. You may be wondering why WordPress has outdated code, and that’s because not all hosts have migrated to PHP 7 yet.

Thanks to the PHP 7 MAR tool, it’s easy to get up-to-speed and ready to migrate all of your PHP projects to the latest version.


Of course, you don’t have to do any of this if you use one of our Outsourced Server Support Services, in which case you can simply ask our expert Linux admins to check for incompatibilities with your application and PHP 7 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on checking your application’s compatibility with PHP 7, please share it with your friends on the social networks using the share shortcut buttons on the left, or simply leave a comment in the comments section below. Thanks.

4 thoughts on “How to Check if Your Application is Compatible with PHP 7

  1. According to the original php7mar repository, it seems that this repository is under archived mode.

    Do you have any alternative PHP 7 migration helpers/assistance?

Leave a Reply

Your email address will not be published. Required fields are marked *